package com.dikeleakagedetection.myapplication.ui.database

import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.DialogFragment
import com.dikeleakagedetection.myapplication.databinding.DlgContourMapBinding

class ContourMapDialogFragment: DialogFragment() {
    private lateinit var binding:DlgContourMapBinding

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
        binding = DlgContourMapBinding.inflate(inflater, container, false)
        dialog!!.setCanceledOnTouchOutside(false)
        return binding.root
    }

    override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)
        initWindow()
        initView()
    }

    private fun initView() {
        binding.tvExportDlgContourMap.setOnClickListener {
            dismiss()
        }
        binding.tvCancelDlgContourMap.setOnClickListener {
            dismiss()
        }
    }

    private fun initWindow() {
        //初始化window相关
        val window = dialog?.window //获取window对象
        window?.apply {
            setBackgroundDrawable(ColorDrawable(Color.WHITE))//设备背景为透明（默认白色）
            attributes.width = 1200
            attributes.gravity = Gravity.CENTER
        }
    }

}